<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
	<rich:panel>
		<h:form>
			<rich:dataTable align="center" width="483" id="groupList" rows="10" columnClasses="col"
				value="#{userGroupBeanForm.allUserGroups}" var="group">
				<f:facet name="header">
					<rich:columnGroup>
						<h:column>
							<h:outputText styleClass="headerText" value="Id" />
						</h:column>
						<h:column>
							<h:outputText styleClass="headerText" value="Group Name" />
						</h:column>
						<h:column>
							<h:outputText styleClass="headerText" value="Group Authority Level" />
						</h:column>
						<h:column>
							<h:outputText styleClass="headerText" value="Action" />
						</h:column>
					</rich:columnGroup>
				</f:facet>

				<h:column>
					<h:outputText value="#{group.ugid}" />
				</h:column>
				<h:column>
					<h:outputText value="#{group.ugname}" />
				</h:column>
				<h:column>
					<h:outputText value="#{group.ugauthoritylevel}" />
				</h:column>
				<h:column>
					<a4j:commandLink value="Edit" oncomplete="#{rich:component('userGroupEdit')}.show()" reRender="userGroupInfo">
						<f:setPropertyActionListener value="#{group}" target="#{userGroupBeanForm.selectedUserGroup}" />
					</a4j:commandLink>
					<br />
					<a4j:commandLink value="Delete" actionListener="#{userGroupBeanForm.remove}" reRender="groupList">
						<f:setPropertyActionListener value="#{group}" target="#{userGroupBeanForm.selectedUserGroup}" />
					</a4j:commandLink>
				</h:column>
			</rich:dataTable>
			<rich:datascroller align="center" for="groupList" maxPages="20" page="#{userGroupBeanForm.scrollerPage}" id="sc" />
		</h:form>
	</rich:panel>
	<rich:panel>
		<rich:modalPanel id="userGroupEdit">
			<f:facet name="header">
				<h:outputText value="Modal Panel Title" />
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" style="cursor:pointer" id="hidelink" />
					<rich:componentControl for="userGroupEdit" attachTo="hidelink" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<h:panelGrid id="userGroupInfo">
					<h:outputLabel for="nameInput" value="Name:" />
					<h:inputText id="nameInput" value="#{userGroupBeanForm.selectedUserGroup.ugname}" />
					<h:outputLabel for="authorityLevelInput" value="Authority Level:" />
					<h:inputText id="authorityLevelInput" value="#{userGroupBeanForm.selectedUserGroup.ugauthoritylevel}" />
					<h:panelGrid columns="2">
						<a4j:commandButton actionListener="#{userGroupBeanForm.save}" oncomplete="#{rich:component('userGroupEdit')}.hide()"
							reRender="groupList" value="Save">
						</a4j:commandButton>
					</h:panelGrid>
				</h:panelGrid>
			</h:form>
		</rich:modalPanel>
	</rich:panel>
</f:view>
</body>
</html>